package com.jx.mst.third.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jx.mst.third.dao.FileLogDao;
import com.jx.mst.third.entity.FileLog;
import com.jx.mst.third.service.FileLogService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 文件日志(FileLog)表服务实现类
 *
 * @author makejava
 * @since 2023-12-25 11:52:16
 */
@Service("fileLogService")
public class FileLogServiceImpl extends ServiceImpl<FileLogDao, FileLog> implements FileLogService {

    @Override
    public void saveLogByFileLogDes(HttpServletRequest request, String fileLogDes, String path) {
        FileLog fileLog = new FileLog();
        fileLog.setFileLogDes(fileLogDes);
        fileLog.setFileLogCreatetime(new Date());
        fileLog.setFileLogPath(path);
        String userId = request.getHeader("userId");
        if(StrUtil.isNotBlank(userId)){
            fileLog.setFileLogCreateUser(Long.valueOf(userId));
        }
        save(fileLog);
    }
}

